/******
* Percent.cpp
*
* Accepts a vector of differences and a string of the text 
* contained in a file and returns the difference in 
* the files
* Returns 100 in the event of an empty disparity 
* vector and a file of size greater than 0
* Returns 0 in the event of an empty disparity
* vector and a file of size 0
******/

#include <utility>
#include <vector>
#include <string>
#include <cmath>
#include <sstream>
#include <cmath>

template<class T> std::string printPercent(std::vector<std::pair<T,T> > c, std::string &textA, std::string &textB)
{
	double fileSize = 0;

	//determines which file is larger in order to avoid overly large output percentages
	if(textA.length()>textB.length())
	{
		fileSize = textA.length();
	}
	else
	{
		fileSize = textB.length();
	}

	//returns # of disparities/# of characters in original file
	if(c.size() == 0)
	{
		if(fileSize == 0)
		{
			std::string finalResult = "The second file is the same as the first file\n";
			return finalResult;
		}
		else
		{
			std::string finalResult = "The second file is completely different from the first file\n";
			return finalResult;
		}
	}

	//calculates the percent difference
	double answer = ((c.size())/fileSize)*100;
	string finalResult;
	std::ostringstream o;
	answer = Math::Round(answer, 2);
	o << answer;


	if(textA.length()>textB.length())
	{
		finalResult.append("The first file is ").append(o.str()).append("% different than the second file\n");
		return finalResult;
	}

		finalResult.append("The first second is ").append(o.str()).append("% different than the first file\n");
		return finalResult;
}



